import uuid
from django.db import models
from django.utils import timezone

"""
模型操作：
    1.修改模型后，字段需要添加默认值，然后重新进行生成：
        python manage.py makemigrations
        python manage.py migrate
        
"""


class ModelDataOverview(models.Model):
    id = models.AutoField(primary_key=True, verbose_name="主键")
    # id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False, verbose_name="主键")
    table_name = models.CharField(blank=True, max_length=64, default=None, verbose_name="表名")
    column_name = models.CharField(blank=True, max_length=64, verbose_name="列名")
    total_num = models.IntegerField(blank=True, verbose_name="总记录数量")
    null_num = models.IntegerField(blank=True, verbose_name="空值记录数量")
    null_rate = models.FloatField(blank=True, verbose_name="空值比率")
    not_null_num = models.IntegerField(blank=True, verbose_name="非空记录数量")
    not_null_rate = models.FloatField(blank=True, verbose_name="非空比率")
    invalid = models.BooleanField(blank=True, default=None, verbose_name="是否有效")
    remark = models.TextField(blank=True, default=None, verbose_name="备注")
    insert_time = models.DateTimeField(blank=True, default=timezone.now, verbose_name="插入时间")

    objects = models.Manager

    class Meta:
        db_table = "model_data_overview"

    def __str__(self):
        """将模型类以字符串的方式输出"""
        return self.column_name
